<template>
  <el-dialog title="添加备注"
             :close-on-click-modal="false"
             :visible.sync="visible">
    <div>
      <div style="padding-left: 0px;padding-bottom: 10px">备注:</div>
      <el-input type="textarea" v-model="remark" :autosize="{minRows: 3, maxRows: 6}"></el-input>
    </div>
    <span slot="footer"
          class="dialog-footer">
      <el-button @click="visible = false">取消</el-button>
      <el-button type="primary"
                 @click="dataFormSubmit()">确定</el-button>
    </span>
  </el-dialog>
</template>

<script>
  export default {
    name: 'addRemark',
    data () {
      return {
        visible: false,
        remark: '',
        id: ''
      }
    },
    methods: {
      init (row) {
        this.visible = true
        this.id = row.id
        this.remark = row.remark
      },
      dataFormSubmit () {
        if(!this.remark) {
          this.$message.error('请输入备注')
          return
        }
        this.$http({
          url: this.$http.adornUrl('/user/add/remark'),
          method: 'post',
          data: this.$http.adornData({
            id: this.id,
            remark: this.remark
          })
        }).then(({ data }) => {
          this.$message({
            message: '操作成功',
            type: 'success',
            duration: 1500,
            onClose: () => {
              this.visible = false
              this.$emit('refreshDataList')
            }
          })
        })
      }
    }
  }
</script>

<style scoped>

</style>
